package map;


import entity.Entity;

/**
 * 
 * @author C. Fox
 * 
 * 
 */
public class ViewArea 
{
	public double x;
	public double y;
	int width, xMargin;
	int height, yMargin;
	Entity focus;
	
	public ViewArea(Entity focus)
	{
		this.focus = focus;
		x = 0;
		y = 0;
		width = Game.width;
		height = Game.height;
	}
	
	public void update()
	{
		float xPos = focus.getPosition().x;
		float yPos = focus.getPosition().y;
		
		if (xPos > width - xMargin)
		{
			x -= focus.getSpeed().x;
		}
			
		else
			x = 0;
		
		if (yPos < yMargin)
		{
			y += focus.getSpeed().y;
		}
			
		else
			y = 0;
		
		if (xPos < xMargin)
		{
			x += focus.getSpeed().x;
		}
		
		if (yPos > height - yMargin)
		{
			y -= focus.getSpeed().y;
		}
	}
}
